package com.wenjiang.common.lang;

import lombok.Data;
import lombok.ToString;

/**
 * 通用的结果集
 */
@Data
@ToString
public class Result {
    //错误代码
    private int code;

    //返回结果
    private Object data;

    //提示信息

    private String msg;




    //成功方法

    public  static Result succ(int code,Object data, String msg){
        Result result =new Result();
        result.setData(data);
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public  static Result succ(Object data, String msg){
        Result result =new Result();
        result.setData(data);
        result.setCode(200);
        result.setMsg(msg);
        return result;
    }

    //成功方法
    public  static Result succ(String msg){
        Result result =new Result();
        result.setCode(200);
        result.setMsg(msg);
        return result;
    }

    //成功方法
    public  static Result succ(Object data){
        Result result =new Result();
        result.setCode(200);
        result.setData(data);
        return result;
    }


    //失败方法
    public  static Result fail(int code, String msg){
        Result result =new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }


    //失败方法
    public  static Result fail(Object data, String msg){
        Result result =new Result();
        result.setData(data);
        result.setCode(500);
        result.setMsg(msg);
        return result;
    }

    public  static Result fail(String msg){

        Result result = new Result();
        result.setCode(500);
        result.setMsg(msg);
        return result;
    }

}
